import { Component, OnInit } from '@angular/core';
import { EChartOption } from 'echarts';
import * as moment from 'moment';
import { DataManagementService } from '../data-management.services';
import { NotificationService } from 'app/shared/service';
import { differenceInCalendarDays } from 'date-fns';
import { TranslateService } from '@ngx-translate/core';
import { SELECT_OPTIONS } from 'app/app.constants';
import { PublicService } from 'app/public/public.service';

@Component({
    selector: 'itmp-technical-alarm-report',
    templateUrl: './technical-alarm-report.component.html',
    styleUrls: ['./technical-alarm-report.component.css']
})
export class TechnicalAlarmReportComponent implements OnInit {
    queryStartTime = null;
    queryEndTime = null;
    dateRange = null;
    startTimeRange = '';
    endTimeRange = '';
    deviceType = [];
    deviceTypeObj = {};
    options: EChartOption;
    option1: EChartOption;
    option2: EChartOption;
    option3: EChartOption;
    echartsIntance: any;
    echartsIntance1: any;
    echartsIntance2: any;
    echartsIntance3: any;
    data = [];
    DEVICEID = [];
    FALUT_COUNT = [];
    FAULT_TYPE = [];
    COUNT = [];
    PERCENTAGE = [];
    total = 0;
    constructor(
        private DMService: DataManagementService,
        private message: NotificationService,
        private translate: TranslateService,
        private pub: PublicService
    ) {}

    ngOnInit() {
        this.getDevTypeList();
        this.initDefaultSearchParam();
        // this.getOption();
        this.translate.onLangChange.subscribe(() => this.getOption());
        this.getData();
    }
    onChartInit(ec: any) {
        this.echartsIntance = ec;
    }
    onChartInit1(ec: any) {
        this.echartsIntance1 = ec;
    }
    onChartInit2(ec: any) {
        this.echartsIntance2 = ec;
    }
    onChartInit3(ec: any) {
        this.echartsIntance3 = ec;
    }

    getDevTypeList() {
        const eqTypeData = this.pub.getSelectOptionsList(SELECT_OPTIONS.EQUIPMENT_TYPE, true);
        this.deviceTypeObj = eqTypeData.object;
    }
    // echarts
    getOption() {
        const tempData = ['Fault Ratios(%)', 'normal Ratios(%)'];
        const tempTime = ['Fault Time(%)', 'normal Time(%)'];
        const translateData = [];
        const translateTimeData = [];
        const translateTyprData = [];
        this.FAULT_TYPE.forEach(item => {
            this.translate.get('DataManagement.TechnicalAlarmReport.' + item).subscribe((res: string) => {
                translateTyprData.push(res);
                this.COUNT.forEach(faultType => {
                    if (faultType.name === item) {
                        faultType.name = res;
                    }
                });
            });
        });
        tempTime.forEach(item => {
            this.translate.get('DataManagement.TechnicalAlarmReport.' + item).subscribe((res: string) => {
                translateTimeData.push(res);
                this.PERCENTAGE.forEach(faultType => {
                    if (faultType.name === item) {
                        faultType.name = res;
                    }
                });
            });
        });
        tempData.forEach(item => {
            this.translate.get('DataManagement.TechnicalAlarmReport.' + item).subscribe((res: string) => {
                translateData.push(res);
                this.FALUT_COUNT.forEach(faultType => {
                    if (faultType.name === item) {
                        faultType.name = res;
                    }
                });
            });
        });
        setTimeout(() => {
            this.options = {
                // title: {
                //     text: `Total: ${this.total}`,
                //     right: 40,
                //     top: 30,
                //     textStyle: {
                //         color: '#484848',
                //         fontSize: 16
                //     }
                // },
                tooltip: {
                    trigger: 'item',
                    formatter: '{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    data: this.deviceType,
                    padding: 50,
                    itemGap: 30,
                    itemHeight: 25,
                    type: 'scroll',
                    textStyle: {
                        color: '#ffffff' //图例颜色
                    }
                },
                series: [
                    {
                        center: ['40%', '50%'], // 饼图的中心（圆心）坐标
                        name: 'data',
                        type: 'pie',
                        radius: ['40%', '70%'],
                        data: this.data,
                        label: {
                            formatter: '{d}%'
                        },
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                    {
                        type: 'pie',
                        radius: ['40%', '50%'],
                        center: ['40%', '50%'],
                        hoverAnimation: false,
                        data: [1],
                        itemStyle: {
                            color: 'rgba(63, 63, 63, 0.2)'
                        },
                        labelLine: {
                            show: false
                        },
                        tooltip: {
                            show: false
                        }
                    }
                ]
            } as EChartOption;
            this.option1 = {
                tooltip: {
                    trigger: 'item',
                    formatter: '{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    // data: this.FAULT_TYPE,
                    data: translateTyprData,
                    padding: 50,
                    itemGap: 30,
                    itemHeight: 25,
                    type: 'scroll',
                    textStyle: {
                        color: '#ffffff' //图例颜色
                    }
                },
                series: [
                    {
                        center: ['40%', '50%'],
                        name: 'data',
                        type: 'pie',
                        radius: ['40%', '70%'],
                        data: this.COUNT,
                        label: {
                            formatter: '{d}%'
                        },
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                    {
                        type: 'pie',
                        radius: ['40%', '50%'],
                        center: ['40%', '50%'],
                        hoverAnimation: false,
                        data: [1],
                        itemStyle: {
                            color: 'rgba(63, 63, 63, 0.2)'
                        },
                        labelLine: {
                            show: false
                        },
                        tooltip: {
                            show: false
                        }
                    }
                ]
            } as EChartOption;
            this.option2 = {
                tooltip: {
                    trigger: 'item',
                    formatter: '{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    // data: ['Fault Ratios(%)', 'normal Ratios(%)'],
                    data: translateData,
                    padding: 50,
                    itemGap: 30,
                    itemHeight: 25,
                    type: 'scroll',
                    textStyle: {
                        color: '#ffffff' //图例颜色
                    }
                },
                series: [
                    {
                        center: ['40%', '50%'],
                        name: 'data',
                        type: 'pie',
                        radius: ['40%', '70%'],
                        data: this.FALUT_COUNT,
                        label: {
                            formatter: '{d}%'
                        },
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                    {
                        type: 'pie',
                        radius: ['40%', '50%'],
                        center: ['40%', '50%'],
                        hoverAnimation: false,
                        data: [1],
                        itemStyle: {
                            color: 'rgba(63, 63, 63, 0.2)'
                        },
                        labelLine: {
                            show: false
                        },
                        tooltip: {
                            show: false
                        }
                    }
                ]
            } as EChartOption;
            this.option3 = {
                tooltip: {
                    trigger: 'item',
                    formatter: '{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    data: translateTimeData,
                    padding: 50,
                    itemGap: 30,
                    itemHeight: 25,
                    type: 'scroll',
                    textStyle: {
                        color: '#ffffff' //图例颜色
                    }
                },
                series: [
                    {
                        center: ['40%', '50%'],
                        name: 'data',
                        type: 'pie',
                        radius: ['40%', '70%'],
                        data: this.PERCENTAGE,
                        label: {
                            formatter: '{d}%'
                        },
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                    {
                        type: 'pie',
                        radius: ['40%', '50%'],
                        center: ['40%', '50%'],
                        hoverAnimation: false,
                        data: [1],
                        itemStyle: {
                            color: 'rgba(63, 63, 63, 0.2)'
                        },
                        labelLine: {
                            show: false
                        },
                        tooltip: {
                            show: false
                        }
                    }
                ]
            } as EChartOption;
        });
    }
    // search每次点击饼图发送数据更新页面(公共)
    packData(res, that) {
        if (res.messagecode === '000000') {
            const map = {};
            const dest = [];
            res.data.forEach((item, i) => {
                const ai = res.data[i];
                if (!map[ai.SELECTTYPE]) {
                    dest.push({
                        SELECTTYPE: ai.SELECTTYPE,
                        data: [ai]
                    });
                    map[ai.SELECTTYPE] = ai;
                } else {
                    dest.forEach((it, j) => {
                        const dj = dest[j];
                        if (dj.SELECTTYPE === ai.SELECTTYPE) {
                            dj.data.push(ai);
                        }
                    });
                }
            });
            that.DEVICEID = [];
            that.FALUT_COUNT = [];
            that.FAULT_TYPE = [];
            that.COUNT = [];
            that.FAULT_TYPE = [];
            that.PERCENTAGE = [];
            for (const item of dest) {
                if (item.SELECTTYPE === '2') {
                    for (const i of item.data) {
                        that.DEVICEID.push(i.DEVICEID);
                        const number = parseInt(`${i.FALUT_COUNT}`);
                        that.FALUT_COUNT.push({ value: number, name: i.DEVICEID });
                    }
                    that.getOption();
                    // that.echartsIntance2.setOption(that.option2, true);
                } else if (item.SELECTTYPE === '1') {
                    for (const i of item.data) {
                        that.FAULT_TYPE.push(i.FAULT_TYPE);
                        const number = parseInt(`${i.COUNT}`);
                        that.COUNT.push({ value: number, name: i.FAULT_TYPE });
                    }
                    that.getOption();
                    // that.echartsIntance1.setOption(that.option1, true);
                } else {
                    for (const i of item.data) {
                        that.FAULT_TYPE.push(i.FAULT_TYPE);
                        const number = parseInt(`${i.PERCENTAGE}`);
                        that.PERCENTAGE.push({ value: number, name: 'Fault Time(%)' });
                    }
                    that.getOption();
                    // that.echartsIntance3.setOption(that.option3, true);
                }
            }
        }
        if (res.data.length === 0) {
            this.message.notify({ type: 'warning', path: 'DataManagement.TrafficDataReport.nodata' });
        }
    }
    // 初始化进来每次点击饼图发送数据更新页面(公共)
    queryData(rest, that) {
        if (rest.messagecode === '000000') {
            const map = {};
            const dest = [];
            rest.data.forEach((item, i) => {
                const ai = rest.data[i];
                if (!map[ai.SELECTTYPE]) {
                    dest.push({
                        SELECTTYPE: ai.SELECTTYPE,
                        data: [ai]
                    });
                    map[ai.SELECTTYPE] = ai;
                } else {
                    dest.forEach((it, j) => {
                        const dj = dest[j];
                        if (dj.SELECTTYPE === ai.SELECTTYPE) {
                            dj.data.push(ai);
                        }
                    });
                }
            });
            that.DEVICEID = [];
            that.FALUT_COUNT = [];
            that.FAULT_TYPE = [];
            that.COUNT = [];
            that.FAULT_TYPE = [];
            that.PERCENTAGE = [];
            for (const item of dest) {
                if (item.SELECTTYPE === '2') {
                    for (const i of item.data) {
                        that.DEVICEID.push(i.SELECTTYPE);
                        that.FALUT_COUNT.push({ value: Number(i.PERCENTAGE), name: 'Fault Ratios(%)' });
                        that.FALUT_COUNT.push({
                            // value: Math.ceil(i.FALUT_COUNT / i.PERCENTAGE * 100 - i.FALUT_COUNT),
                            value: 100 - Number(i.PERCENTAGE),
                            name: 'normal Ratios(%)'
                        });
                    }
                    that.getOption();
                    // that.echartsIntance2.setOption(that.option2, true);
                } else if (item.SELECTTYPE === '1') {
                    for (const i of item.data) {
                        that.FAULT_TYPE.push(i.FAULT_TYPE);
                        const number = parseInt(`${i.COUNT}`);
                        that.COUNT.push({ value: number, name: i.FAULT_TYPE });
                    }
                    that.getOption();
                    // that.echartsIntance1.setOption(that.option1, true);
                } else {
                    for (const i of item.data) {
                        that.FAULT_TYPE.push(i.FAULT_TYPE);
                        const number = Number(i.PERCENTAGE);
                        that.PERCENTAGE.push({ value: number, name: 'Fault Time(%)' });
                        that.PERCENTAGE.push({ value: 100 - number, name: 'normal Time(%)' });
                    }
                    that.getOption();
                    // that.echartsIntance3.setOption(that.option3, true);
                }
            }
        }
        if (rest.data.length === 0) {
            this.message.notify({ type: 'warning', path: 'DataManagement.TrafficDataReport.nodata' });
        }
    }
    search() {
        // tslint:disable-next-line:max-line-length
        if (this.queryStartTime === null || this.queryEndTime === null) {
            this.message.notify({ type: 'warning', path: 'DataManagement.TrafficDataReport.select_notify' });
        } else {
            const queryParam = `startDateRange=${this.queryStartTime},endDateRange=${this.queryEndTime}`;
            this.DMService.getAlarmRep(queryParam).subscribe(res => {
                if (res.messagecode === '000000') {
                    this.deviceType = [];
                    this.data = [];
                    this.total = 0;
                    for (const item of res.data) {
                        item.DEVICETYPE = this.deviceTypeObj[item.DEVICETYPE] || '';
                        this.deviceType.push(item.DEVICETYPE);
                        const number = parseInt(`${item.COUNT}`);
                        this.data.push({ value: number, name: item.DEVICETYPE });
                        this.total += number;
                    }
                    this.getOption();
                    // tslint:disable-next-line: no-shadowed-variable
                    const that = this;
                    that.echartsIntance.on('click', function eConsole(param) {
                        if (param.name === 'VMS') {
                            const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=0`;
                            that.DMService.getAlarmChildRep(a).subscribe(rest => {
                                that.queryData(rest, that);
                            });
                        } else if (param.name === 'AID') {
                            const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=1`;
                            that.DMService.getAlarmChildRep(a).subscribe(rest => {
                                that.queryData(rest, that);
                            });
                        } else if (param.name === 'LPR') {
                            const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=2`;
                            that.DMService.getAlarmChildRep(a).subscribe(rest => {
                                that.queryData(rest, that);
                            });
                        } else if (param.name === 'CCTV') {
                            const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=3`;
                            that.DMService.getAlarmChildRep(a).subscribe(rest => {
                                that.queryData(rest, that);
                            });
                        } else if (param.name === 'TSC') {
                            const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=4`;
                            that.DMService.getAlarmChildRep(a).subscribe(rest => {
                                that.queryData(rest, that);
                            });
                        }
                    });
                }
                if (res.data.length === 0) {
                    this.message.notify({ type: 'warning', path: 'DataManagement.TrafficDataReport.nodata' });
                }
                this.getOption();
            });
            this.deviceType = [];
            this.data = [];
            this.DEVICEID = [];
            this.FALUT_COUNT = [];
            this.FAULT_TYPE = [];
            this.COUNT = [];
            this.FAULT_TYPE = [];
            this.PERCENTAGE = [];
            this.total = 0;
            // this.getData();
            // 左上角总数据饼图点击事件
            // const that = this;
            // this.echartsIntance.on('click', function eConsole(param) {
            //     if (param.name === 'VMS') {
            //         const queryData = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=0`;
            //         that.DMService.getAlarmChildRep(queryData).subscribe(res => {
            //             that.packData(res, that);
            //         });
            //     } else if (param.name === 'AID') {
            //         const queryData = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=1`;
            //         that.DMService.getAlarmChildRep(queryData).subscribe(res => {
            //             that.packData(res, that);
            //         });
            //     } else if (param.name === 'LPR') {
            //         const queryData = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=2`;
            //         that.DMService.getAlarmChildRep(queryData).subscribe(res => {
            //             that.packData(res, that);
            //         });
            //     } else if (param.name === 'CCTV') {
            //         const queryData = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=3`;
            //         that.DMService.getAlarmChildRep(queryData).subscribe(res => {
            //             that.packData(res, that);
            //         });
            //     } else if (param.name === 'TSC') {
            //         const queryData = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},deviceType=4`;
            //         that.DMService.getAlarmChildRep(queryData).subscribe(res => {
            //             that.packData(res, that);
            //         });
            //     }
            // });
        }
    }
    initDefaultSearchParam() {
        // 获取当天日期
        const day1 = new Date();
        day1.setTime(day1.getTime());
        const thisDay = day1.getFullYear() + '-' + (day1.getMonth() + 1) + '-' + day1.getDate();
        // 获取明天日期
        const hour = day1.getHours(); // 得到小时
        const minu = day1.getMinutes(); // 得到分钟
        const day3 = new Date();
        day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
        const nextDay = day3.getFullYear() + '-' + (day3.getMonth() + 1) + '-' + day3.getDate();
        const todayStart = thisDay + ` 00:00`;
        const todayEnd = thisDay + ` ${hour}:${minu}`;
        this.startTimeRange = '00:00';
        this.endTimeRange = `${hour}:${minu}`;
        this.dateRange = [todayStart, todayEnd];
        this.queryStartTime = moment(day1.getTime()).format('YYYY-MM-DD');
        this.queryEndTime = moment(day1.getTime()).format('YYYY-MM-DD');
    }
    getData() {
        // 初始化时的默认数据
        const queryParam = `startDateRange=${this.queryStartTime},endDateRange=${this.queryEndTime}`;
        this.DMService.getAlarmRep(queryParam).subscribe(res => {
            if (res.messagecode === '000000') {
                this.deviceType = [];
                this.data = [];
                this.total = 0;
                for (const item of res.data) {
                    item.DEVICETYPE = this.deviceTypeObj[item.DEVICETYPE] || '';
                    this.deviceType.push(item.DEVICETYPE);
                    const number = parseInt(`${item.COUNT}`);
                    this.data.push({ value: number, name: item.DEVICETYPE });
                    this.total += number;
                }
                this.getOption();
                const that = this;
                // that.echartsIntance.on('click', function eConsole(param) {
                //     if (param.name === 'VMS') {
                //         // tslint:disable-next-line: max-line-length
                //         const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},startTimeRange=${
                //             that.startTimeRange
                //             },endTimeRange=${that.endTimeRange},deviceType=0`;
                //         that.DMService.getAlarmChildRep(a).subscribe(rest => {
                //             that.queryData(rest, that);
                //         });
                //     } else if (param.name === 'AID') {
                //         // tslint:disable-next-line: max-line-length
                //         const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},startTimeRange=${
                //             that.startTimeRange
                //             },endTimeRange=${that.endTimeRange},deviceType=1`;
                //         that.DMService.getAlarmChildRep(a).subscribe(rest => {
                //             that.queryData(rest, that);
                //         });
                //     } else if (param.name === 'LPR') {
                //         // tslint:disable-next-line: max-line-length
                //         const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},startTimeRange=${
                //             that.startTimeRange
                //             },endTimeRange=${that.endTimeRange},deviceType=2`;
                //         that.DMService.getAlarmChildRep(a).subscribe(rest => {
                //             that.queryData(rest, that);
                //         });
                //     } else if (param.name === 'CCTV') {
                //         // tslint:disable-next-line: max-line-length
                //         const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},startTimeRange=${
                //             that.startTimeRange
                //             },endTimeRange=${that.endTimeRange},deviceType=3`;
                //         that.DMService.getAlarmChildRep(a).subscribe(rest => {
                //             that.queryData(rest, that);
                //         });
                //     } else if (param.name === 'TSC') {
                //         // tslint:disable-next-line: max-line-length
                //         const a = `startDateRange=${that.queryStartTime},endDateRange=${that.queryEndTime},startTimeRange=${
                //             that.startTimeRange
                //             },endTimeRange=${that.endTimeRange},deviceType=4`;
                //         that.DMService.getAlarmChildRep(a).subscribe(rest => {
                //             that.queryData(rest, that);
                //         });
                //     }
                // });
            }
            if (res.data.length === 0) {
                this.message.notify({ type: 'warning', path: 'DataManagement.TrafficDataReport.nodata' });
            }
            // this.getOption();
        });
        // // const that = this;
        // // 初始化时其余三个子饼图默认数据为AID的子数据
        // const queryData = `startDateRange=2015-11,endDateRange=2019-10,deviceType=1`;
        // // tslint:disable-next-line:no-shadowed-variable
        // this.DMService.getAlarmChildRep(queryData).subscribe(res => {
        //     if (res.messagecode === '000000') {
        //         // 将获取的数据包装成自己想要的数据格式
        //         const map = {};
        //         const dest = [];
        //         res.data.forEach((item, i) => {
        //             const ai = res.data[i];
        //             if (!map[ai.SELECTTYPE]) {
        //                 dest.push({
        //                     SELECTTYPE: ai.SELECTTYPE,
        //                     data: [ai]
        //                 });
        //                 map[ai.SELECTTYPE] = ai;
        //             } else {
        //                 dest.forEach((it, j) => {
        //                     const dj = dest[j];
        //                     if (dj.SELECTTYPE === ai.SELECTTYPE) {
        //                         dj.data.push(ai);
        //                     }
        //                 });
        //             }
        //         });
        //         for (const item of dest) {
        //             if (item.SELECTTYPE === '2') {
        //                 for (const i of item.data) {
        //                     this.DEVICEID.push(i.DEVICEID);
        //                     const number = parseInt(`${i.FALUT_COUNT}`);
        //                     this.FALUT_COUNT.push({ value: number, name: i.DEVICEID });
        //                 }
        //                 this.echartsIntance2.setOption(this.option2, true);
        //             } else if (item.SELECTTYPE === '1') {
        //                 for (const i of item.data) {
        //                     this.FAULT_TYPE.push(i.FAULT_TYPE);
        //                     const number = parseInt(`${i.COUNT}`);
        //                     this.COUNT.push({ value: number, name: i.FAULT_TYPE });
        //                 }
        //                 this.echartsIntance1.setOption(this.option1, true);
        //             } else {
        //                 for (const i of item.data) {
        //                     this.FAULT_TYPE.push(i.FAULT_TYPE);
        //                     const number = parseInt(`${i.PERCENTAGE}`);
        //                     this.PERCENTAGE.push({ value: `${i.PERCENTAGE}`, name: 'Fault Time(%)' });
        //                 }
        //                 this.echartsIntance3.setOption(this.option3, true);
        //             }
        //         }
        //     }
        // });
    }
    onOk(result: Date): void {}
    onChange(result: Date): void {
        const t1 = moment(result[0]).format('YYYY-MM-DD HH:mm');
        const t2 = moment(result[1]).format('YYYY-MM-DD HH:mm');
        this.queryStartTime = t1.split(' ')[0];
        this.queryEndTime = t2.split(' ')[0];
        this.startTimeRange = t1.split(' ')[1];
        this.endTimeRange = t2.split(' ')[1];
        // this.queryStartTime = t1;
        // this.queryEndTime = t2;
        // this.getData();
    }
    // 禁用今天之后的日期选择
    range(start: number, end: number): number[] {
        const result: number[] = [];
        for (let i = start; i < end; i++) {
            result.push(i);
        }
        return result;
    }

    disabledDate = (current: Date): boolean => {
        // Can not select days before today and today
        return differenceInCalendarDays(current, new Date()) > 0;
    };

    disabledDateTime: object = () => {
        return {
            nzDisabledHours: () => this.range(0, 24).splice(4, 20),
            nzDisabledMinutes: () => this.range(30, 60),
            nzDisabledSeconds: () => [55, 56]
        };
    };

    disabledRangeTime: object = (value: Date[], type: 'start' | 'end') => {
        if (type === 'start') {
            return {
                nzDisabledHours: () => this.range(0, 60).splice(4, 20),
                nzDisabledMinutes: () => this.range(30, 60),
                nzDisabledSeconds: () => [55, 56]
            };
        }
        return {
            nzDisabledHours: () => this.range(0, 60).splice(20, 4),
            nzDisabledMinutes: () => this.range(0, 31),
            nzDisabledSeconds: () => [55, 56]
        };
    };
}
